package com.seelyn.rhea.mvc.render.provider;

import com.seelyn.rhea.mvc.context.Request;
import com.seelyn.rhea.mvc.context.Response;
import com.seelyn.rhea.mvc.render.Render;

import java.util.Map;

/**
 * @author linfeng
 * @since 2016/1/20
 */
public class RedirectRender implements Render<RedirectView> {

    private static final String REDIRECT_FLASH_KEY = "_redirect_flash_key_";

    @Override public void render(RedirectView redirectView, Request request, Response response) {
        Map<String, Object> flashMap = redirectView.getFlashMap();
        request.session().attribute(REDIRECT_FLASH_KEY, flashMap);

        response.redirect(redirectView.getUrl());
    }

}
